<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  author: Jsonor
  date: 2018/3/21 14:46
  description: Country view
--%>
<%@ page contentType="text/html;charset=UTF-8" isELIgnored="false" %>
<html>
<head>
  <title>城市信息</title>
  <link rel="stylesheet" href="/static/bootstrap-3.3.7-dist/css/bootstrap.min.css"/>

  <style>
    * {
      margin: auto;
      text-align: center;

    }
  </style>
</head>
<body>
<h1>城市信息</h1>
<div style="margin: 8px;">
  <form action="/pagesearchCountry.action" >
    Region : <input id="region" type="text" name="region">
    <input type="submit"  value="搜索"/>
<%--onclick="checkregion();"--%>
    <a href="/view/pageadd.jsp" style="text-align: right">添加</a>
  </form>
</div>
<table border="1px solid black" style="align: center;font-size: 13px;">
  <tbody style="">
  <tr>
    <td>Count</td>
    <td>Code</td>
    <td>Name</td>
    <td>Region</td>
    <td>SurfaceArea</td>
    <td>IndepYear</td>
    <td>Population</td>
    <td>LifeExpectancy</td>
    <td>GNP</td>
    <td>HeadOfState</td>
    <td>Capital</td>
    <td>Code2</td>
    <td>Function</td>
  </tr>

  <c:forEach var="item" items="${page.countryList}" varStatus="vs">
    <tr>
      <td>${vs.count}</td>
      <td>${item.code}</td>
      <td>${item.name}</td>
      <td>${item.region}</td>
      <td>${item.surfaceArea}</td>
      <td>${item.indepYear}</td>
      <td>${item.population}</td>
      <td>
          ${item.lifeExpectancy}
      </td>
      <td>${item.gnp}</td>
      <td>${item.headOfState}</td>
      <td>${item.capital}</td>
      <td>${item.code2}</td>
      <td>
        <a href="/pagesinglefind/${item.code}.action">修改</a>
        |
        <a href="javascript:;" onclick="already('${item.code}')">删除</a>
      </td>
    </tr>
  </c:forEach>
  </tbody>
</table>

<ul class="pagination">
  <c:if test="${page.pageid != 0}">
    <li><a href="/pagefind.action?pageid=${page.pageid - 1}">&laquo;</a></li>
  </c:if>
  <c:if test="${page.pageid == 0}">
    <li><a href="javascript:;">&laquo;</a></li>
  </c:if>

  <c:forEach begin="${page.begin}" end="${page.end}" step="1" var="as">
    <c:if test="${as == page.pageid}">
      <li class="active">
        <a href="/pagefind.action?pageid=${as}">${as}</a>
      </li>
    </c:if>
    <c:if test="${as != page.pageid}">
      <li>
        <a href="/pagefind.action?pageid=${as}">${as}</a>
      </li>
    </c:if>
  </c:forEach>

  <c:if test="${page.pageid != page.total}">
    <li><a href="/pagefind.action?pageid=${page.pageid + 1}">&raquo;</a></li>
  </c:if>
  <c:if test="${page.pageid == page.total}">
    <li><a href="javascript:;">&raquo;</a></li>
  </c:if>
</ul>
</body>

<script type="text/javascript" src="/static/css/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="/static/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script>

    function already(ev){
        if(confirm("确定要删除吗"))
        {
            location ="/pagedelete/"+ev+".action";
        }
    }


//  checkregion = function() {
//      var region = $(":input[name='region']").val;
//      if(region != null){
//          location = "/pagesearchCountry.action?region="+ region;
//      }else{
//          location = "/pagefind.action?pageid=0";
//      }
//    }
</script>
</html>
